/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2022-11-06
 * Time: 22:24
 */


class ListNode {
    int val;
    ListNode next;
    ListNode() {}
    ListNode(int val) { this.val = val; }
    ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}


public class Solution {
    public ListNode deleteDuplicates(ListNode head) {
        if(head==null||head.next==null){
            return head;
        }
        if(head.val!=head.next.val){
            //不相等
            deleteDuplicates(head.next);
        }else{
            //相等
            head.next=head.next.next;
            deleteDuplicates(head);
        }
        return head;
    }
}
